#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, dp[1000006][3][2];
char s[1000006], t[1000006];
/*
0 -> NONE, to 3,4,5
1 -> 1, to 
2 -> 2
3 -> 3
4 -> 1 3
5 -> 2 3
*/

int dfs(int i, int eq, int rev) {
	if (i == n + 1) return 0; 
	if (dp[i][eq][rev] != -1) return dp[i][eq][rev];
	char nows = s[i] - '0';
	if (eq) nows = eq - 1;
	if (rev) nows ^= 1;
	if (nows != t[i] - '0') return 1ll << 60;
	int ans = 1ll << 60;
	for (int neq = 0; neq <= 2; ++neq) {
		for (int nrev = 0; nrev <= 1; ++nrev) {
			int tmp = dfs(i + 1, neq, nrev);
			if (neq != 0 && neq != eq) ++tmp;
			if (nrev != 0 && nrev != rev) ++tmp;
			ans = min(ans, tmp);
		}
	}
	return dp[i][eq][rev] = ans;
}
signed main() {
	freopen("hard.in", "r", stdin); freopen("hard.out", "w", stdout);
	scanf("%lld%s%s", &n, s + 1, t + 1);
	memset(dp, 255, sizeof(dp));
	int ans = 1ll << 60;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 2; ++j) {
			ans = min(ans, dfs(1, i, j) + (!!i) + (j));
		}
	}
	cout << ans << "\n";
	return 0;
}
